import React, { Component } from 'react';
import { StyleSheet, View } from 'react-native';
import InOrOutBound from './inOrOutBound';
import SparePart from './sparePart';

class PartMainView extends Component {
  static navigationOptions = {
    header: null,
  }

  constructor(props) {
    super(props);
    this.state = {
      pageIndex: 'SparePart',
    };
  }

  changePageIndex = (index) => {
    this.setState({ pageIndex: index });
  }

  render() {
    let mPage = null;
    if (this.state.pageIndex === 'InOrOutBound') {
      mPage = <InOrOutBound changePageIndex={this.changePageIndex} />;
    } else if (this.state.pageIndex === 'SparePart') {
      mPage = <SparePart changePageIndex={this.changePageIndex} />;
    }
    return (
      <View style={styles.container}>
        {mPage}
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
  },
});

export default PartMainView;
